import unittest
from unittest import TestLoader, TestSuite
from HtmlTestRunner import HTMLTestRunner
import os


# 创建报告目录
os.makedirs("reports", exist_ok=True)

print("创建测试报告目录")
# 加载测试用例
loader = TestLoader()
suite = TestSuite()
print("加载测试用例成功")
# 添加测试模块，将模块加入测试用例队列中，然后按照排序执行
suite.addTests(loader.loadTestsFromName("tests.test_upload"))
suite.addTests(loader.loadTestsFromName("tests.test_tall"))
print('添加测试模板成功')
# 运行测试并生成HTML报告
# with open("reports/test_report.html", "w") as f:
#     runner = HTMLTestRunner(
#         stream=f,
#         report_title="Selenium Test Report",
#         descriptions=True,
#         verbosity=2
#     )
#     runner.run(suite)
#print('测试报告已生成，请到reports/test_report.html目录查看')


runner = unittest.TextTestRunner()
runner.run(suite)
